package com.wing.sell.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wing.sell.dao.OrderOfferDetailDao;
import com.wing.sell.model.entity.OrderOfferDetail;
import com.wing.sell.model.request.OrderOfferDetailForm;
import com.wing.sell.model.response.OrderOfferDetailVO;
import com.wing.sell.service.OrderOfferDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 报价明细表-ServiceImpl
 *
 * @author
 */
@Service
@Slf4j
public class OrderOfferDetailServiceImpl extends ServiceImpl<OrderOfferDetailDao, OrderOfferDetail> implements OrderOfferDetailService {

    @Override
    public int add(OrderOfferDetailForm orderOfferDetailForm) {

        //校验

        OrderOfferDetail orderOfferDetail =new OrderOfferDetail();
        CopyOptions copyOptions = CopyOptions.create()
        .setEditable(OrderOfferDetail.class)
        .setIgnoreError(true)
        .setIgnoreNullValue(true);
        BeanUtil.copyProperties(orderOfferDetailForm, orderOfferDetail, copyOptions);

        return baseMapper.insert(orderOfferDetail);
    }

    @Override
    public List<OrderOfferDetailVO> list4app(Map<String, Object> params) {
        return baseMapper.list4app(params);
    }

    @Override
    public Page<OrderOfferDetailVO> pageList4app(Page page, Map<String, Object> params) {
        List<OrderOfferDetailVO> list = baseMapper.list4app(page, params);
        page.setRecords(list);
        return page;
    }

    @Override
    public OrderOfferDetailVO get4appById(Long id) {
        return baseMapper.get4appById(id);
    }
}
